package main

import (
	"fmt"
	"go_test/src/code.song.study/domain"
	"go_test/src/code.song.study/match"
	"math/rand"
	"time"
)

func init() {
	rand.Seed(time.Now().Unix())
}
func main() {
	buyTest()
}

func buyTest() {
	for i := 0; i < 10; i++ {
		price := rand.Float64()
		amount := rand.Float64()
		orderInfo := domain.NewOrderInfo(price, amount)
		match.PushBuyOrder(&orderInfo)
		fmt.Println(orderInfo)
	}
	count := match.BuyOrderBookSize()
	fmt.Println(">>>>>>.", count)
	for i := 0; i < count; i++ {
		order := match.PollBuyOrder()
		fmt.Println(*order)
	}
}

func SellTest() {

	for i := 0; i < 10; i++ {
		price := rand.Float64()
		amount := rand.Float64()
		orderInfo := domain.NewOrderInfo(price, amount)
		match.PushSellOrder(&orderInfo)
		fmt.Println(orderInfo)
	}

	fmt.Println(">>>>>>>>>>>")
	size := match.SellOrderBookSize()

	for i := 0; i < size; i++ {
		order := match.PollSellOrder()
		fmt.Println(*order)
	}
}
